﻿using DryIoc;
using HandyControl.Controls;
using IntoTheVoid.ViewModels;
using ScrollControl;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace IntoTheVoid.Views
{
    public enum TabEnum
    {
        CommonSetting,
        GameResourcesSetting,
        VersionSetting,
        QuickOpenSetting
    };


    /// <summary>
    /// SettingView.xaml 的交互逻辑
    /// </summary>
    public partial class SettingView : UserControl
    {
        public SettingView()
        {
            InitializeComponent();
            this.DataContext = new SettingViewModel();


        }

		public void OpenUserDialog(object sender, MouseButtonEventArgs e)
		{
			/*			App.Current.Dispatcher.Invoke((Action)(() =>
						{
							var view = new UserAgreementView();
							var dialog = Dialog.Show(view);
							var viewModel = (dialog.Content as UserAgreementView).DataContext as UserAgreementViewModel;
							viewModel.ParentDialog = dialog;
						}));*/
			System.Diagnostics.Process.Start("https://www.jinzhangshu.com/#policy/user");
		}
		private void SetterPanel_ScrollChanged(object sender, ScrollChangedEventArgs e)
        {
            if (e.VerticalOffset > 0 && e.VerticalOffset <= 420)
            {
                SetterCommonSetButton.IsChecked = true;
            }
            else if (e.VerticalOffset > 420 && e.VerticalOffset <= 480)
            {
               SetterGameResourceButton.IsChecked = true;
            }
            else if (e.VerticalOffset > 480 && e.VerticalOffset <= 620)
            {
				SetterLauncherVersionButton.IsChecked = true;
			}
            else if (e.VerticalOffset > 620)
            {
				SetterQuickOpenButton.IsChecked = true;
			}
		}
		private void tb_PreviewTextInput(object sender, TextCompositionEventArgs e)
		{
			Regex re = new Regex("[^0-9.-]+");
			e.Handled = re.IsMatch(e.Text);
		}

		private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
		{
			System.Diagnostics.Process.Start("https://www.taptap.cn/moment/522171643934542530");
		}

		private void OpenChildPrivacyDialog(object sender, MouseButtonEventArgs e)
		{
			System.Diagnostics.Process.Start("https://www.jinzhangshu.com/#policy/children");
		}
		private void OpenPrivacyDialog(object sender, MouseButtonEventArgs e)
		{
			System.Diagnostics.Process.Start("https://www.jinzhangshu.com/#policy/privacy");
		}

    }
	class RadioBtConvter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value == null ? false : value.Equals(parameter);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value != null && value.Equals(true) ? parameter : Binding.DoNothing;
        }
    }
}
